<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>

<body>
    <table id="tab">
        <tr>
            <td>
                <input class="ipt2" name="" type="checkbox" />
                <span>苹果 - </span><span class="sn">10</span>
                <input class="text_box" name="" type="text" value="1" />
            </td>
        </tr>
        <tr>
            <td>
                <input class="ipt2" name="" type="checkbox" />
                <span>putao - </span><span class="sn">16</span>
                <input class="text_box" name="" type="text" value="1" />
            </td>
        </tr>
    </table>
    <p>总价:<label id="total"></label></p>
    <input type="checkbox" id="cbx">全选
</body>
<script>
    
    $(function () {
        $(".ipt2").click(function () {
            var t = $(this).parent().find('input[class*=text_box]');
            t.val(parseInt(t.val()) + 1)
            setTotal();
        })
        
        function setTotal() {
            var s = 0;
            $("#tab td").each(function () {
                s += parseInt($(this).find('input[class*=text_box]').val()) *
                    parseFloat($(this).find('span[class*=sn]').text());
            });
            $("#total").html(s.toFixed(2));
        }
        setTotal();
    })
    
</script>
</script>

</html>